package com.adt.studioms.api;

import com.adt.studioms.om.PaymentTx;
import com.adt.studioms.om.PaymentTxDetail;
import com.asao.baseware.core.api.hibernate.HibernateDAOAwareAPI;

public class PaymentTxAPI extends HibernateDAOAwareAPI<PaymentTx> {

    protected Class<PaymentTx> getEntityClass() {
        return PaymentTx.class;
    }

    public PaymentTx createPaymentTx(String code,
                                     Long paymentDate,
                                     String paymentReason,
                                     long amount,
                                     String receiptNumber,
                                     Long receiptDate,
                                     String payer) {
        PaymentTx ptx = new PaymentTx();
        ptx.setCode(code);
        ptx.setPaymentDate(paymentDate);
        ptx.setReceiptNumber(receiptNumber);
        ptx.setReceiptDate(receiptDate);
        ptx.setPayer(payer);
        
        PaymentTxDetail ptxd = ptx.createDetail();
        ptxd.setAmount(amount);
        ptxd.setDescription(paymentReason);
        
        save(ptx);
        
        return ptx;
    }
}
